import { Body, Controller, Post } from '@nestjs/common';
import { LoginDto } from './dto/login.dto';
import { LoginService } from './login.service';
import { ApiTags, ApiOperation, ApiCreatedResponse } from '@nestjs/swagger';

@ApiTags('用户登录')
@Controller('login')
export class LoginController {
  // 使用方式需要使用@Inject的方式
  constructor (
    private readonly loginService: LoginService,
  ) { }

  @ApiOperation({
    summary: '用户登录',
    description: '用户名和密码登录',
  })
  @ApiCreatedResponse({
    type: LoginDto,
    description: '用户登录DTO'
  })
  @Post()
  async login(
    @Body() data:LoginDto
  ) {
   return this.loginService.login(data)
  }
}
